﻿using System;

namespace NodeJS
{
    public abstract class Path
    {
        private Path() { }

        /// <summary>
        /// Normalize a string path, taking care of '..' and '.' parts.
        /// When multiple slashes are found, they're replaced by a single one; when the path contains a trailing slash, it is preserved. On Windows backslashes are used.
        /// </summary>
        /// <param name="path"></param>
        /// <returns></returns>
        public abstract string Normalize(string path);

        /// <summary>
        /// Join all arguments together and normalize the resulting path.
        /// </summary>
        /// <param name="args"></param>
        /// <returns></returns>
        public abstract string Join(params string[] args);

        /// <summary>
        /// If last string isn't already absolute, other arguments are prepended in right to left order, until an absolute path is found. If after using all paths still no absolute path is found, the current working directory is used as well. 
        /// Think of it is as a sequence of cd commands in a shell.
        /// The resulting path is normalized, and trailing slashes are removed unless the path gets resolved to the root directory.
        /// </summary>
        /// <param name="args"></param>
        /// <returns></returns>
        public abstract string Resolve(params string[] args);

        /// <summary>
        /// At times we have two absolute paths, and we need to derive the relative path from one to the other. 
        /// </summary>
        /// <param name="from"></param>
        /// <param name="to"></param>
        /// <returns></returns>
        public abstract string Relative(string from, string to);

        /// <summary>
        /// Return the directory name of a path. Similar to the Unix dirname command.
        /// </summary>
        /// <param name="path"></param>
        /// <returns></returns>
        public abstract string Dirname(string path);

        /// <summary>
        /// Return the last portion of a path. Similar to the Unix basename command.
        /// </summary>
        /// <param name="path"></param>
        /// <param name="ext"></param>
        /// <returns></returns>
        public abstract string Basename(string path, string ext = "");

        /// <summary>
        /// Return the extension of the path, from the last '.' to end of string in the last portion of the path. If there is no '.' in the last portion of the path or the first character of it is '.', then it returns an empty string.
        /// </summary>
        /// <param name="path"></param>
        /// <returns></returns>
        public abstract string Extname(string path);

        /// <summary>
        /// The platform-specific file separator. '\' or '/'.
        /// </summary>
        public readonly string Sep = "";

        /// <summary>
        /// The platform-specific path delimiter, ';' or ':'.
        /// </summary>
        public readonly string Delimiter = "";
        
    }
}
